import { Entity, PrimaryGeneratedColumn, Column, OneToOne, ManyToOne, OneToMany, ManyToMany, JoinTable } from 'typeorm';
import { Dept } from 'src/modules/system/dept/entities/dept.entity';
import { Duty } from 'src/modules/system/duty/entities/duty.entity';
import { UserError } from 'src/modules/questionbank/user_error/entities/user_error.entity';
@Entity('exe_book')
export class Exebook {
    @PrimaryGeneratedColumn('uuid')   //自增id
    Id: string;
    
    @ManyToOne(() => Dept, (Dept) => Dept.Exebooks)  //dept.id
    Dept: Dept; // 关联角色实体

    @ManyToOne(() => Duty, (Duty) => Duty.Exebooks)  //duty.id
    Duty: Duty; // 关联角色实体
    
    @OneToMany(() => UserError, UserError => UserError.exe)
    userLinks: Exebook[];
    //审核流

    // 题目创建时间
    @Column({
        type: 'timestamp',
        default: () => 'CURRENT_TIMESTAMP',
      })
    CreateTime: Date;

    //题目类型 1-单选 2-多选 3-填空 4-判断       
    @Column()
    Questiontype: number; 

    //题目内容
    @Column()
    Questiontext: string; 

    //选项内容及答案  
    //JSON单选/多选	存储选择题选项，格式示例：[{"text":"选项A","correct":0}, {"text":"选项B","correct":1}]
    @Column("simple-json",{ nullable: true})
    Options: { text: string; correct: number }[];
    //判断题	1-正确  0-错误
    @Column({ nullable: true }) 
    Tfanswer: number; 
    //填空题存储填空题答案，格式示例：[{"position":1,"answer":"答案1"}, {"position":2,"answer":"答案2"}]
    @Column("simple-json",{ nullable: true })
    Fillanswer: { position: number; answer: string }[];

    //题目解析/答案解析 
    @Column({ nullable: true})
    Explanation: string; 

    //题目难度,难度等级(1-5)，1表示最简单
    @Column()
    Difficulty: number; 

    // 删除标志，1为已删除，0为未删除
    @Column({default: 0})
    Deleted: number; 

}
